<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section 13.2.&nbsp; Daemon Characteristics</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch13lev1sec1.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch13lev1sec3.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch13lev1sec2"></a>
<h3 class="docSection1Title">13.2. Daemon Characteristics</h3>
<p class="docText">Let's look at some common system daemons and how they relate to the concepts of process groups, controlling terminals, and sessions that we described in <a class="docLink" href="ch09.html#ch09">Chapter 9</a>. The <tt>ps</tt>(1) command prints the status of various processes in the system. There are a multitude of optionsconsult your system's manual for all the details. We'll execute</P>

<pre>
   ps -axj
</pre><BR>

<p class="docText">under BSD-based systems to see the information we need for this discussion. The <tt>-a</tt> option shows the status of processes owned by others, and <tt>-x</tt> shows processes that don't have a controlling terminal. The <tt>-j</tt> option displays the job-related information: the session ID, process group ID, controlling terminal, and terminal process group ID. <a name="idd1e94613"></a><a name="idd1e94616"></a><a name="idd1e94619"></a><a name="idd1e94624"></a><a name="idd1e94629"></a><a name="idd1e94634"></a><a name="idd1e94639"></a><a name="idd1e94644"></a>Under System Vbased systems, a similar command is <tt>ps -efjc</tt>. (In an attempt to improve security, some UNIX systems don't allow us to use <tt>ps</tt> to look at any processes other than our own.) The output from <tt>ps</tt> looks like</p>
<P><table cellspacing="0" FRAME="void" RULES="none" cellpadding="5"><colgroup><col width="50"><col width="50"><col width="50"><col width="50"><col width="30"><col width="50"><col width="50"><col width="220"></colgroup><thead></thead><TR><TD class="docTableCell" align="right" valign="top"><p class="docText"><tt>PPID</tt></p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText"><tt>PID</tt></P></td><TD class="docTableCell" align="right" valign="top"><p class="docText"><tt>PGID</tt></p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText"><tt>SID</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>TTY</tt></P></td><TD class="docTableCell" align="right" valign="top"><p class="docText"><tt>TPGID</tt></P></td><td class="docTableCell" align="right" valign="top"><p class="docText"><tt>UID</tt></p></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>COMMAND</tt>
</p></TD></tr><TR><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">?</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">-1</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">0</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>init</tt>
</P></td></TR><TR><TD class="docTableCell" align="right" valign="top"><p class="docText">1</p></TD><td class="docTableCell" align="right" valign="top"><p class="docText">2</P></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">1</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">1</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">?</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">-1</p></TD><td class="docTableCell" align="right" valign="top"><p class="docText">0</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>[keventd]</tt>
</p></td></tr><tr><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">3</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><TD class="docTableCell" align="left" valign="top"><p class="docText">?</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">-1</P></TD><td class="docTableCell" align="right" valign="top"><p class="docText">0</P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>[kapmd]</tt>
</p></TD></tr><TR><TD class="docTableCell" align="right" valign="top"><p class="docText">0</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">5</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">1</P></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><TD class="docTableCell" align="left" valign="top"><p class="docText">?</p></TD><td class="docTableCell" align="right" valign="top"><p class="docText">-1</P></td><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>[kswapd]</tt>
</p></td></tr><tr><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">6</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">1</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">?</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">-1</P></TD><td class="docTableCell" align="right" valign="top"><p class="docText">0</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>[bdflush]</tt>
</P></TD></tr><TR><TD class="docTableCell" align="right" valign="top"><p class="docText">0</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">7</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></TD><td class="docTableCell" align="right" valign="top"><p class="docText">1</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">?</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">-1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>[kupdated]</tt>
</p></td></tr><tr><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1009</P></TD><td class="docTableCell" align="right" valign="top"><p class="docText">1009</P></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">1009</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">?</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">-1</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">32</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>portmap</tt>
</P></td></TR><TR><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1048</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">1048</p></TD><td class="docTableCell" align="right" valign="top"><p class="docText">1048</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">?</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">-1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>syslogd -m 0</tt></p></td></tr><tr><TD class="docTableCell" align="right" valign="top"><p class="docText">1</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">1335</P></TD><td class="docTableCell" align="right" valign="top"><p class="docText">1335</P></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">1335</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">?</P></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">-1</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">0</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>xinetd -pidfile /var/run/xinetd.pid</tt>
</p></td></tr><tr><TD class="docTableCell" align="right" valign="top"><p class="docText">1</p></TD><td class="docTableCell" align="right" valign="top"><p class="docText">1403</P></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">?</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">-1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>[nfsd]</tt>
</P></TD></tr><TR><TD class="docTableCell" align="right" valign="top"><p class="docText">1</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">1405</P></TD><td class="docTableCell" align="right" valign="top"><p class="docText">1</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">1</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">?</P></TD><td class="docTableCell" align="right" valign="top"><p class="docText">-1</P></TD><td class="docTableCell" align="right" valign="top"><p class="docText">0</p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>[lockd]</tt>
</P></td></TR><tr><TD class="docTableCell" align="right" valign="top"><p class="docText">1405</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1406</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">?</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">-1</p></td><TD class="docTableCell" align="right" valign="top"><p class="docText">0</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>[rpciod]</tt>
</P></TD></tr><TR><TD class="docTableCell" align="right" valign="top"><p class="docText">1</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">1853</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">1853</P></td><TD class="docTableCell" align="right" valign="top"><p class="docText">1853</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">?</P></td><td class="docTableCell" align="right" valign="top"><p class="docText">-1</p></td><TD class="docTableCell" align="right" valign="top"><p class="docText">0</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>crond</tt>
</P></td></tr><tr><td class="docTableCell" align="right" valign="top"><p class="docText">1</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">2182</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">2182</p></td><td class="docTableCell" align="right" valign="top"><p class="docText">2182</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">?</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">-1</p></TD><TD class="docTableCell" align="right" valign="top"><p class="docText">0</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>/usr/sbin/cupsd</tt>
</P></TD></tr></table></P><br>
<p class="docText">We have removed a few columns that don't interest us, such as the accumulated CPU time. The column headings, in order, are the parent process ID, process ID, process group ID, session ID, terminal name, terminal process group ID (the foreground process group associated with the controlling terminal), user ID, and command string.</P>
<blockquote>
<p class="docText">The system that this <tt>ps</tt> command was run on (Linux) supports the notion of a session ID, which we mentioned with the <tt>setsid</tt> function in <a class="docLink" href="ch09lev1sec5.html#ch09lev1sec5">Section 9.5</a>. The session ID is simply the process ID of the session leader. A BSD-based system, however, will print the address of the <tt>session</tt> structure corresponding to the process group that the process belongs to (<a class="docLink" href="ch09lev1sec11.html#ch09lev1sec11">Section 9.11</a>).</P>
</blockquote>
<p class="docText">The system processes you see will depend on the operating system implementation. Anything with a parent process ID of 0 is usually a kernel process started as part of the system bootstrap procedure. (An exception to this is <tt>init</tt>, since it is a user-level command started by the kernel at boot time.) Kernel processes are special and generally exist for the entire lifetime of the system. They run with superuser privileges and have no controlling terminal and no command line.</P>
<p class="docText">Process 1 is usually <tt>init</tt>, as we described in <a class="docLink" href="ch08lev1sec2.html#ch08lev1sec2">Section 8.2</a>. It is a system daemon responsible for, among other things, starting system services specific to various run levels. These services are usually implemented with the help of their own daemons.</p>
<p class="docText">On Linux, the <tt>kevenTD</tt> daemon provides process context for running scheduled functions in the kernel. The <tt>kapmd</tt> daemon provides support for the advanced power management features available with various computer systems. The <tt>kswapd</tt> daemon is also known as the pageout daemon. It supports the virtual memory subsystem by writing dirty pages to disk slowly over time, so the pages can be reclaimed.</P>
<p class="docText">The Linux kernel flushes cached data to disk using two additional daemons: <tt>bdflush</tt> and <tt>kupdated</tt>. The <tt>bdflush</tt> daemon flushes dirty buffers from the buffer cache back to disk when available memory reaches a low-water mark. The <tt>kupdated</tt> daemon flushes dirty pages back to disk at regular intervals to decrease data loss in the event of a system failure.</p>
<p class="docText"><a name="idd1e95317"></a><a name="idd1e95320"></a><a name="idd1e95325"></a><a name="idd1e95330"></a><a name="idd1e95335"></a><a name="idd1e95340"></a><a name="idd1e95345"></a><a name="idd1e95350"></a><a name="idd1e95355"></a><a name="idd1e95360"></a><a name="idd1e95365"></a><a name="idd1e95370"></a><a name="idd1e95375"></a><a name="idd1e95380"></a><a name="idd1e95385"></a>The portmapper daemon, <tt>portmap</tt>, provides the service of mapping RPC (Remote Procedure Call) program numbers to network port numbers. The <tt>syslogd</tt> daemon is available to any program to log system messages for an operator. The messages may be printed on a console device and also written to a file. (We describe the <tt>syslog</tt> facility in <a class="docLink" href="ch13lev1sec4.html#ch13lev1sec4">Section 13.4</a>.)</P>
<p class="docText">We talked about the <tt>inetd</tt> daemon (<tt>xinetd</tt>) in <a class="docLink" href="ch09lev1sec3.html#ch09lev1sec3">Section 9.3</a>. It listens on the system's network interfaces for incoming requests for various network servers. The <tt>nfsd</tt>, <tt>lockd</tt>, and <tt>rpciod</tt> daemons provide support for the Network File System (NFS).</P>
<p class="docText">The <tt>cron</tt> daemon (<tt>crond</tt>) executes commands at specified dates and times. Numerous system administration tasks are handled by having programs executed regularly by <tt>cron</tt>. The <tt>cupsd</tt> daemon is a print spooler; it handles print requests on the system.</p>
<p class="docText">Note that most of the daemons run with superuser privilege (a user ID of 0). None of the daemons has a controlling terminal: the terminal name is set to a question mark, and the terminal foreground process group is 1. The kernel daemons are started without a controlling terminal. The lack of a controlling terminal in the user-level daemons is probably the result of the daemons having called <tt>setsid</tt>. All the user-level daemons are process group leaders and session leaders and are the only processes in their process group and session. Finally, note that the parent of most of these daemons is the <tt>init</tt> process.</p>

<a href="17021535.html"><img src="images/pixel.gif" alt="" width="1" height="1" border="0"></a><ul></ul></TD></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch13lev1sec1.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch13lev1sec3.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--176-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--176-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
